﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Serialization;


namespace tswe.umbraco.languageEditor.classes.xml
{
    public class Key
    {
        [XmlAttribute(AttributeName = "alias", DataType = "string")]
        public string Alias;

        [XmlIgnore]
        public string Value;

        [XmlText]
        public XmlNode[] _value
        {
            get
            {
                XmlDataDocument doc = new XmlDataDocument();
                XmlCDataSection cd = doc.CreateCDataSection(this.Value);
                return new XmlNode[] {cd};
            }
            set
            {

                if (value != null && value.Length >= 1)
                    this.Value = value[0].Value;
            }
        }

        //[XmlText(typeof(string))] //....., XmlElement(typeof(XmlCDataSection))]
        //[XmlText(typeof(XmlCDataSection), DataType = "string")]

        //[XmlElement("code", typeof(XmlCDataSection)]

        //[ XmlText(typeof(XmlCDataSection))]
        //public XmlCDataSection Value
        //{
        //  get { return value; }
        //  set 
        //  {
        //      //value = value; 
        //  }
        //}

        //public XmlCDataSection value;

        //public Key()
        //{
        //    XmlDocument doc = new XmlDocument();
        //    value = doc.CreateCDataSection("Hello, World!");
        //}
    }
}
